<script setup>
import { ref } from "vue";
import { commonTypeList } from "@/assets/deviceTypes/types.js";

const props = defineProps({
  devices: {
    type: Array,
    default: function () {
      return [];
    },
  },
});

const getTypeName = (typeId) => {
  let name = "";
  commonTypeList.some((item) => {
    if (typeId === item.id) {
      name = item.name;
      return true;
    }
  });
  return name;
};
</script>

<template>
  <div id="container">
    <el-table :data="props.devices" height="220" style="width: 92%">
      <el-table-column prop="id" label="设备号"></el-table-column>
      <el-table-column prop="typeId" label="设备类型">
        <template #default="{ row }">
          {{ getTypeName(row.typeId) }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<style lang="scss" scoped>
#container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  padding: 5px;
}
</style>